package com.example.demo.heima.reactor;

import java.io.IOException;
import java.nio.channels.Selector;

/**
 * ******************************************************
 *
 * @author liugh9
 * @version 1.0
 * @classname ServerThead
 * @description
 * @date 2023/08/12 16:07
 * <p>
 * ******************************************************
 */
public abstract class ServerThead extends Thread {
    protected Selector selector;

    public ServerThead(String name) {
        super(name);
        try {
            this.selector = Selector.open();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void closeSelector() {
        try {
            this.selector.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    protected void weakUpSelector() {
        selector.wakeup();
    }
}
